//
// Created by xuyang on 2019/1/11.
//



#include <zconf.h>
#include <string.h>
#include <printf.h>

int main(){
    int _pipe[2]={0,0};
    int ret=pipe(_pipe);

    pid_t id =fork();
    if(id>0){
       close(_pipe[0]);//关闭读
        char* buff="heelo";
        printf("%d\n",getpid());
        write(_pipe[1],buff,strlen(buff));
    }else{
        close(_pipe[1]);
        char arr[100];
        read(_pipe[0],arr, sizeof(arr));
        printf("%d\n",getpid());
        printf("%s\n",arr);
    }
    return 0;
}